import mongoose from 'mongoose'

// 数据库连接ip
const connectHost = '//127.0.0.1'
// 连接端口
const connectPort = '27017'
// 数据库表名称
const PlaygroundName = 'medicinal'

export default (app) => {
  mongoose.connect(`mongodb:${connectHost}:${connectPort}/${PlaygroundName}`)
  mongoose.connection.once('open',() => {
    console.log('数据库连接成功')
  })
  
  mongoose.connection.on('error',() => {
      console.log('数据库连接错误')
  })
  
  mongoose.connection.on('close',() => {
      console.log('数据库连接断开')
  })
}
